<?php
/**
 * Created by PhpStorm.
 * User: Guangpeng Chen
 * 资源库列表
 * Date: 15-7-27
 * Time: 下午3:27
 */
use \PFT\Db;
use \PFT\Resource\PftResource;
include '/var/www/html/new/d/common/page.php';
include '/var/www/html/new/d/module/common/Db.class.php';
$dbConf = include '/var/www/html/new/d/module/common/db.conf.php';// 远端服务器配置信息
Db::Conf($dbConf['localhost']);

$currentPage = $_REQUEST["currentPage"]? intval($_REQUEST["currentPage"]):1;
$pageSize    = $_REQUEST["pageSize"]?intval($_REQUEST["pageSize"]):10;
$offset      = ($currentPage-1)*$pageSize;
include 'PftResource.php';
$obj = new PftResource(Db::Connect());

//删除
if ($_GET['action']=='remove' && $_GET['id']) {
    $sql = "UPDATE pft_resource SET status=1 WHERE id=? LIMIT 1";
    $stmt = Db::Connect()->prepare($sql);
    if  ( $stmt->execute(array(intval($_GET['id']))) ){
        echo 1;
    } else {
        echo 0;
    }
} else {
    $data  = $obj->show(array(), false, $offset, $pageSize);
    $type_cnt = $obj->CountProduct();
    $total = $obj->show(array(), true);
}
Db::Close();
include ROOT_PATH .'tpl/pft_resource/resource.html';